package com.sanjiahantang.ythshopping.adapter.home;

import android.content.Context;
import android.view.View;
import android.widget.AbsListView;

import com.sanjiahantang.ythshopping.R;
import com.sanjiahantang.ythshopping.model.BestNewHot;
import com.sanjiahantang.ythshopping.model.BestNewHotModel;
import com.sanjiahantang.ythshopping.views.HomewMoreView;

import java.util.List;

/**
 * Created by Administrator on 2017/6/8.
 */

public class RecommendHolder extends MyBaseViewHolder implements AbsListView.OnScrollListener,HomewMoreView{
    private Context context;

    private MyGridView gridView;

    private List<BestNewHot> datas;
    GvJptjAdapter gvadapter;
    boolean loadmay=false;

    public RecommendHolder(View itemView, Context context, List<BestNewHot> datas) {
        super(itemView);
        this.context = context;
        this.datas = datas;

        gridView = (MyGridView) itemView.findViewById(R.id.home_goods_grid);

        gridView.setOnScrollListener(this);
    }

    @Override
    void bindData() {

        //判断是否需要重新请求
        if (!datas.isEmpty() ) {
            //直接加载数据
            gvadapter=new GvJptjAdapter(context, datas);
            gridView.setAdapter(gvadapter);
            loadmay=true;
        }
    }

    @Override
    public void onScrollStateChanged(AbsListView absListView, int i) {

    }

    @Override
    public void onScroll(AbsListView absListView, int first, int visibleItemCount, int totalItemCount) {

    }

    @Override
    public void getHomeMore(BestNewHotModel model) {
        if (model.getData().size()!=0)
        {
            gvadapter.AddDate(model.getData());
            loadmay=true;
        }else {
            loadmay=false;
        }


    }

}
